home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / giochi / chinacha.lha / ChinaChallenge3 / C / cc3.h < prev    next >
C/C++ Source or Header  |  1994-05-08  |  8KB  |  296 lines

  1. /************************************************************************
  2. *                                    *
  3. * Header File for China Challenge III - the C Version            *
  4. *                                    *
  5. * author    : Gunther Nikl                        *
  6. * created    : 8-may-94                        *
  7. * last change    : 8-may-94                        *
  8. *                                    *
  9. *************************************************************************/
  10.  
  11. #ifndef _CC3_H
  12. #define _CC3_H
  13.  
  14. /* all includes */
  15.  
  16. #include <exec/memory.h>
  17. #include <dos/dosextens.h>
  18. #include <devices/audio.h>
  19. #include <hardware/cia.h>
  20. #include <graphics/gfx.h>
  21. #include <graphics/rastport.h>
  22. #include <intuition/screens.h>
  23. #include <intuition/intuition.h>
  24. #include <proto/intuition.h>
  25. #include <proto/graphics.h>
  26. #include <proto/alib.h>
  27. #include <proto/exec.h>
  28. #include <proto/dos.h>
  29.  
  30. LONG sprintf(STRPTR buffer, STRPTR fmt, ...);
  31.  
  32. /* own function prototypes */
  33.  
  34. VOID InitMusic();
  35. LONG MakeGfx();
  36. VOID CloseGfx();
  37. VOID FreeMusic();
  38.  
  39. VOID DoIDCMP(ULONG imClass, ULONG imCode);
  40.  
  41. VOID ProjectAbout();
  42. VOID ProjectQuit();
  43.  
  44. VOID OptNewGame();
  45. VOID OptUndoMove();
  46. VOID OptUndoAll();
  47. VOID OptLoadDragon();
  48. VOID OptSaveDragon();
  49. VOID OptMusic();
  50.  
  51. LONG CheckPos();
  52.  
  53. VOID MakeDragon();
  54. LONG Random(ULONG);
  55. VOID ShowDragon();
  56. VOID PrintPieces();
  57.  
  58. BPTR ReqFile(LONG);
  59. VOID ChangeFunc();
  60.  
  61. /* useful structure definition */
  62.  
  63. struct About
  64.   UBYTE pens[2],x,y,text[24];
  65. };
  66.  
  67. struct Undo
  68. {
  69.   UWORD pos1,pos2;
  70. };
  71.  
  72. struct Dragon
  73. {
  74.   struct Undo UndoTable[60];
  75.   BYTE PieceTable[288];
  76. };
  77.  
  78. /* gfx stuff */
  79.  
  80. #define DEPTH    3L
  81. #define WIDTH  320L
  82. #define HEIGHT 200L
  83.  
  84. #define MAXCOUNT 120L
  85.  
  86. #define SAMPLESIZE 104072L
  87.  
  88. #define ciaa (*((struct CIA*)0xbfe001L))
  89.  
  90. UBYTE ArpName[]       = "arp.library";
  91. UBYTE AudioName[]     = "audio.device";
  92. UBYTE TopazName[]     = "topaz.font";
  93.  
  94. UBYTE SampleName[]    = "Sample";
  95. UBYTE PieceFmt[]      = "%3ld";
  96. UBYTE BlankStr[]      = "   ";
  97.  
  98. UBYTE AboutStr[]      = "About";
  99. UBYTE QuitStr[]       = "Quit";
  100. UBYTE NewGameStr[]    = "New game";
  101. UBYTE UndoMoveStr[]   = "Undo last move";
  102. UBYTE UndoAllStr[]    = "Undo all moves";
  103. UBYTE LoadDragonStr[] = "Load Dragon";
  104. UBYTE SaveDragonStr[] = "Save Dragon";
  105. UBYTE PlayMusicStr[]  = "Play Music";
  106. UBYTE OptionsStr[]    = "Options";
  107. UBYTE ProjectStr[]    = "Project";
  108.  
  109. struct About About[] =
  110. { { {4,0},9,  9,"  China Challenge III  " },
  111.   { {4,0},9, 16,"  -------------------  " },
  112.   { {4,0},9, 29,"    written 1991 by    " },
  113.   { {2,0},9, 44,"     Dirk Hoffmann     " },
  114.   { {4,0},6, 60,"   rewritten 1993 by   " },
  115.   { {2,0},9, 75,"     Gunther Nikl      " },
  116.   { {3,0},9, 89,"This game is Freeware !" },
  117.   { {3,0},9, 99,"       Enjoy ...       " },
  118.   { {2,0},9,112," (dedicated to Astrid) " } };
  119.  
  120. UBYTE Version[]       = "$VER: China Challenge III 1.0a (8.5.94)";
  121. #define Title (Version+6)
  122.  
  123. struct TextAttr TopazFont =
  124. { TopazName,8,FS_NORMAL,FPF_ROMFONT };
  125.  
  126. struct NewScreen NewScreen =
  127. { 0,0, WIDTH,HEIGHT, DEPTH, 4,2, 0 /* LORES */,
  128.   SCREENQUIET | SCREENBEHIND | CUSTOMSCREEN, &TopazFont, Title, NULL, NULL };
  129.  
  130. UWORD ColorTab[] =
  131. { 0x000,0xfeb,0xfe9,0xcb7,0xa43,0xc52,0x4a0,0x86b };
  132.  
  133. struct NewWindow NewWindow =
  134. { 0,1, WIDTH,HEIGHT-2, 2,4,
  135.   MENUPICK | MOUSEBUTTONS, ACTIVATE | BORDERLESS | BACKDROP,
  136.   NULL,NULL,NULL,NULL,NULL,
  137.   WIDTH,HEIGHT-2, WIDTH,HEIGHT-2, CUSTOMSCREEN };
  138.  
  139. struct NewWindow AboutWindow =
  140. { 57,55, 200,120, 2,2,
  141.   VANILLAKEY | MOUSEBUTTONS, NOCAREREFRESH | RMBTRAP | ACTIVATE | BORDERLESS,
  142.   NULL,NULL,NULL,NULL,NULL,
  143.   200,120,200,120, CUSTOMSCREEN };
  144.  
  145. struct IntuiText MenuText[] =
  146. { { 2,4, JAM2,  3,1, NULL, AboutStr,      NULL },
  147.   { 2,4, JAM2,  3,1, NULL, QuitStr,       NULL },
  148.   { 2,4, JAM2,  3,1, NULL, NewGameStr,    NULL },
  149.   { 2,4, JAM2,  3,1, NULL, UndoMoveStr,   NULL },
  150.   { 2,4, JAM2,  3,1, NULL, UndoAllStr,    NULL },
  151.   { 2,4, JAM2,  3,1, NULL, LoadDragonStr, NULL },
  152.   { 2,4, JAM2,  3,1, NULL, SaveDragonStr, NULL },
  153.   { 2,4, JAM2, 13,1, NULL, PlayMusicStr,  NULL } };
  154.  
  155. #define IFLAGS1 (HIGHCOMP | ITEMENABLED | COMMSEQ | ITEMTEXT)
  156. #define IFLAGS2 (CHECKED | IFLAGS1 | MENUTOGGLE | CHECKIT)
  157.  
  158. struct MenuItem MenuItems[] =
  159. { { &MenuItems[1], 2, 2, 80,11, IFLAGS1, NULL, &MenuText[0], NULL, 'a', NULL, 0 },
  160.   { NULL,          2,14, 80,11, IFLAGS1, NULL, &MenuText[1], NULL, 'q', NULL, 0 },
  161.  
  162.   { &MenuItems[3], 2, 2,150,11, IFLAGS1, NULL, &MenuText[2], NULL, 'n', NULL, 0 },
  163.   { &MenuItems[4], 2,14,150,11, IFLAGS1, NULL, &MenuText[3], NULL, 'b', NULL, 0 },
  164.   { &MenuItems[5], 2,26,150,11, IFLAGS1, NULL, &MenuText[4], NULL, 'g', NULL, 0 },
  165.   { &MenuItems[6], 2,38,150,11, IFLAGS1, NULL, &MenuText[5], NULL, 'l', NULL, 0 },
  166.   { &MenuItems[7], 2,50,150,11, IFLAGS1, NULL, &MenuText[6], NULL, 's', NULL, 0 },
  167.   { NULL         , 2,62,150,11, IFLAGS2, NULL, &MenuText[7], NULL, 'm', NULL, 0 } };
  168.  
  169. struct Menu MenuStrip[] =
  170. { { &MenuStrip[1],  2,2, 60,10, MENUENABLED, ProjectStr, &MenuItems[0], 0,0,0,0 },
  171.   { NULL,          70,2, 60,10, MENUENABLED, OptionsStr, &MenuItems[2], 0,0,0,0 } };
  172.  
  173. WORD Coords[] =
  174. { 0,0, 28,0, 28,33, 0,33, 0,0 };
  175.  
  176. struct Border Border[] =
  177. { {   2,84, 1,2, JAM2, 5, &Coords[0], &Border[1] },
  178.   { 290,84, 1,2, JAM2, 5, &Coords[0], NULL       } };
  179.  
  180. struct IntuiText MoveIText =
  181. { 2,5, JAM2, 283,53, NULL, BlankStr, NULL };
  182.  
  183. UBYTE PosTable[] =
  184. { 0xFF,0x8F,0x1F,0xFE,0xE7,0x7F,0xF8,0xF1,0xFF,
  185.   0xFC,0x03,0x0F,0xF8,0x81,0x1F,0xF0,0xC0,0x3F,
  186.   0x60,0x00,0x0F,0xF0,0x00,0x0F,0xF0,0x00,0x06,
  187.   0x00,0x00,0x00,0xF0,0x00,0x0F,0x00,0x00,0x00 };
  188.  
  189. ULONG BackGroundTab[] =
  190. { 0,0,160,0,0,99,160,99 };
  191.  
  192. ULONG APenTab[] =
  193. { 0,5,0,2 };
  194.  
  195. UBYTE ChannelMap[4] =
  196. { 3,5,10,12 };
  197.  
  198. extern struct Image Images[];
  199.  
  200. /* variables */
  201.  
  202. struct Screen *ScrPtr;
  203. struct Window *WinPtr;
  204. APTR SampleBuf;
  205. LONG PiecePos1,PiecePos2;
  206. ULONG RandVal,PieceCount;
  207. ULONG TwoSelected,OnePiece;
  208. BYTE Music,EndAll,AudioOpen;
  209. struct MsgPort AudioPort;
  210. struct IOAudio AudioIO;
  211. struct RastPort RastPort;
  212. struct BitMap BitMap;
  213. UBYTE EntryTable[MAXCOUNT];
  214. struct Dragon NewDragon;
  215.  
  216. /* arp filerequest structure */
  217.  
  218. struct FileReq
  219. {
  220.   APTR  fr_Hail;
  221.   APTR  fr_File;
  222.   APTR  fr_Dir;
  223.   APTR  fr_Window;
  224.   UBYTE fr_Flags;
  225.   UBYTE fr_res1;
  226.   APTR  fr_Func;
  227.   LONG  fr_res2;
  228. };
  229.  
  230. /* cc3 request definition */
  231.  
  232. struct ChinaReq
  233. {
  234.   struct FileReq FReq;
  235.   UWORD  Pad;
  236.   UBYTE  DirBuf[256];
  237.   UBYTE  FileBuf[128];
  238. };
  239.  
  240. /* arp inlines */
  241.  
  242. static __inline ULONG
  243. FileRequest (struct Library *ArpBase,struct FileReq *req)
  244. {
  245.   register ULONG _res __asm("d0");
  246.   register struct Library *a6 __asm("a6") = ArpBase;
  247.   register struct FileReq *a0 __asm("a0") = req;
  248.   __asm __volatile ("jsr a6@(-294)"
  249.   : "=r" (_res)
  250.   : "r" (a6), "r" (a0)
  251.   : "a0","a1","d0","d1", "memory");
  252.   return _res;
  253. }
  254.  
  255. static __inline VOID
  256. TackOn (struct Library *ArpBase,UBYTE *dir, UBYTE *file)
  257. {
  258.   register struct Library *a6 __asm("a6") = ArpBase;
  259.   register UBYTE *a0 __asm("a0") = dir;
  260.   register UBYTE *a1 __asm("a1") = file;
  261.   __asm __volatile ("jsr a6@(-624)"
  262.   : /* no output */
  263.   : "r" (a6), "r" (a0), "r" (a1)
  264.   : "a0","a1","d0","d1", "memory");
  265. }
  266.   
  267. static __inline BPTR 
  268. ArpOpen (struct Library *ArpBase,UBYTE *name,LONG accessMode)
  269. {
  270.   register BPTR  _res  __asm("d0");
  271.   register struct Library *a6 __asm("a6") = ArpBase;
  272.   register UBYTE *d1 __asm("d1") = name;
  273.   register LONG d2 __asm("d2") = accessMode;
  274.   __asm __volatile ("jsr a6@(-0x1e)"
  275.   : "=r" (_res)
  276.   : "r" (a6), "r" (d1), "r" (d2)
  277.   : "a0","a1","d0","d1","d2", "memory");
  278.   return _res;
  279. }
  280.  
  281. /*
  282. ** NewList() as macro
  283. */
  284.  
  285. #define NEWLIST(l) ((l)->lh_Head = (struct Node *)&(l)->lh_Tail, \
  286.                     (l)->lh_TailPred = (struct Node *)&(l)->lh_Head)
  287.  
  288. #endif /* _CC3_H */
  289.  
  290. /************************************************************************
  291. *                                    *
  292. * end of Header File for China Challenge III - the C Version        *
  293. *                                    *
  294. *************************************************************************/
  295.